// 迭代，贪心
var validPalindrome = function (s) {
    let l = 0, r = s.length - 1
    const isPalindrome = (s, l, r) => {
        while (l < r) {
            if (s[l] !== s[r]) {
                return false
            }
            l++
            r--
        }
        return true
    }

    while (l < r) {
        if (s[l] !== s[r]) {
            return isPalindrome(s, l + 1, r) || isPalindrome(s, l, r - 1)
        }
        l++
        r--
    }
    return true
};

// 递归
var validPalindrome = function (s, l = 0, r = s.length - 1, type = 1) {
    if(type === 1) {
        while(l < r) {
            if(s[l] !== s[r]) {
                validPalindrome(s, l+1, r, 2) || validPalindrome(s, l, r-1, 2)
            }
            l++
            r--
        }
        return true
    }
    else {
        while(l < r) {
            if(s[l] !== s[r]) {
                return false
            }
            l++
            r--
        }
        return true
    }
}